package findContentChildren;

import java.util.Arrays;

public class Solution {
    public int findContentChildren(int[] g, int[] s) {

        // 贪心
        Arrays.sort(g);
        Arrays.sort(s);
        int res = 0;
        int i = g.length-1;
        int j = s.length-1;
        while(i>=0&&j>=0){
            if(g[i]<=s[j]){
                i--;
                j--;
                res++;
            }else {
                i--;
            }
        }
        return res;
        // 1 3 6 8 9
        // 1 2 6 7 10
        // 10->9
        // 7->6
        // 6->3
        // 2->1
    }
}
